package com.ruoyi.bizsys.service.impl;

import java.math.BigDecimal;
import java.util.List;
import java.util.Arrays;

import com.ruoyi.bizsys.domain.BatchJobMonitoring;
import com.ruoyi.bizsys.mapper.BatchJobMonitoringMapper;
import com.ruoyi.bizsys.service.IBatchJobMonitoringService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bizsys.mapper.IncreasedLimitLogMapper;
import com.ruoyi.bizsys.domain.IncreasedLimitLog;
import com.ruoyi.bizsys.service.IIncreasedLimitLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 提额日志Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class IncreasedLimitLogServiceImpl extends ServiceImpl<IncreasedLimitLogMapper, IncreasedLimitLog> implements IIncreasedLimitLogService {

    @Autowired
    private IncreasedLimitLogMapper increasedLimitLogMapper;

    /**
     * 查询提额日志
     *
     * @param id 提额日志ID
     * @return 提额日志
     */
    @Override
    public IncreasedLimitLog selectIncreasedLimitLogById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询提额日志列表
     *
     * @param increasedLimitLog 提额日志
     * @return 提额日志
     */
    @Override
    public List<IncreasedLimitLog> selectIncreasedLimitLogList(IncreasedLimitLog increasedLimitLog) {
        return this.list(new QueryWrapper<>(increasedLimitLog).last("order by id desc"));
    }

    /**
     * 新增提额日志
     *
     * @param increasedLimitLog 提额日志
     * @return 结果
     */
    @Override
    public int insertIncreasedLimitLog(IncreasedLimitLog increasedLimitLog) {
        increasedLimitLog.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(increasedLimitLog);
    }

    /**
     * 修改提额日志
     *
     * @param increasedLimitLog 提额日志
     * @return 结果
     */
    @Override
    public int updateIncreasedLimitLog(IncreasedLimitLog increasedLimitLog) {
        increasedLimitLog.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateById(increasedLimitLog);
    }

    /**
     * 批量删除提额日志
     *
     * @param ids 需要删除的提额日志ID
     * @return 结果
     */
    @Override
    public int deleteIncreasedLimitLogByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除提额日志信息
     *
     * @param id 提额日志ID
     * @return 结果
     */
    @Override
    public int deleteIncreasedLimitLogById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public Double getLineByNow(String customerNo) {
        return increasedLimitLogMapper.getLineByNow(customerNo);
    }

    @Override
    public IncreasedLimitLog getIncreasedAmtByCust(String custNo) {
        return increasedLimitLogMapper.getIncreasedAmtByCust(custNo);
    }

    public BigDecimal increasedSumByType(String custNo,String type) {
        return increasedLimitLogMapper.increasedSumByType(custNo,type);
    }
}
